const express = require("express");
const router = express.Router();
const controllers = require("../../controllers/common");
const exec = require("child_process").execFile;
// 保存路牌信息
router.post(`/saveSign`, async (req, res) => {
  const results = await controllers.saveSign(req.body);
  res.json(results);
});
// 删除路牌
router.post(`/delSign`, async (req, res) => {
  const results = await controllers.delSign(req.body);
  res.json(results);
});
// 获取路牌列表
router.post(`/getSignList`, async (req, res) => {
  const results = await controllers.getSignList(req.body);
  res.json(results);
});
// 保存漫游路线
router.post(`/saveRouteLine`, async (req, res) => {
  const results = await controllers.saveRouteLine(req.body);
  res.json(results);
});
// 获取所有漫游路线
router.post(`/getAllRouteLines`, async (req, res) => {
  const results = await controllers.getAllRouteLines(req.body);
  res.json(results);
});
// 保存矢量路线
router.post(`/saveVectorLine`, async (req, res) => {
  const results = await controllers.saveVectorLine(req.body);
  res.json(results);
});
// 获取所有矢量路线
router.post(`/getAllVectorLines`, async (req, res) => {
  const results = await controllers.getAllVectorLines(req.body);
  res.json(results);
});
router.get(`/openAppExe`, async (req, res) => {
  const path2 = "C:\\Users\\Administrator\\Desktop\\NAP\\NAP.exe";
  try {
    exec(path2, function (err, data) {
      if (err) {
        throw err;
      }
      console.log(data.toString());
      res.json({ code: 200, msg: "启动成功" });
    });
  } catch (error) {
    res.json({ code: 200, msg: "启动成功" });
  }
});

module.exports = router;
